package com.d3works.apps.stock.service;

import com.d3works.apps.stock.db.StockLocationLine;
import com.d3works.apps.stock.db.StockMoveLine;
import com.d3works.apps.stock.db.WapHistory;
import java.time.LocalDate;

public interface WapHistoryService {

  /**
   * Create a new wap history line in given stock location line. The WAP ({@link
   * StockLocationLine#avgPrice} must already be updated in the stock location line.
   *
   * <p>The origin will be {@link
   * com.d3works.apps.stock.db.repo.WapHistoryRepository#ORIGIN_MANUAL_CORRECTION}
   *
   * @param stockLocationLine a stock location line with updated WAP
   * @return the saved wap history
   */
  WapHistory saveWapHistory(StockLocationLine stockLocationLine);

  /**
   * Create a new wap history line in given stock location line. The WAP ({@link
   * StockLocationLine#avgPrice} must already be updated in the stock location line.
   *
   * <p>Set the origin using given stock move line.
   *
   * @param stockLocationLine a stock location line with updated WAP
   * @param stockMoveLine the stock move line that caused the WAP change
   * @return the saved wap history
   */
  WapHistory saveWapHistory(StockLocationLine stockLocationLine, StockMoveLine stockMoveLine);

  /**
   * Same as {@link #saveWapHistory(StockLocationLine, StockMoveLine)}, but with a personalized date
   * instead of today date and origin
   *
   * @param stockLocationLine
   * @param stockMoveLine
   * @param date
   * @return
   */
  WapHistory saveWapHistory(StockLocationLine stockLocationLine, LocalDate date, String origin);
}
